<!DOCTYPE html>
<html lang="en">

<head>
 <meta charset="UTF-8">
 <meta name="viewport"
  content="width=device-width, initial-scale=1.0, minimum-scale=1,maximum-scale=1,user-scalable=no">
 <meta http-equiv="X-UA-Compatible" content="ie=edge">
 <title data-ch="恐龙探险" data-en="Dinosaur Adventure" class="document_title">恐龙探险</title>
 <script src="js/jquery-3.3.1.min.js"></script>
 <script src="js/layer.js"></script>
 <script src="js/common.js"></script>
 <script src="js/rem.js"></script>
 <link rel="stylesheet" href="css/common.css">
 <style>
  .layui-m-layercont {padding: 0 !important;}
  .layui-m-layershade{ background: none !important;}
  .layui-m-layerchild{ background: #000 !important; width: 70% !important;}
  .layui-m-layercont{ color: #fff;
   padding: 0.3rem !important;
   text-align: center !important;
  }
  .jui_top_bar,.jui_top_left,.jui_top_right{
   display: box;
   display: -webkit-box;
   display: -moz-box;
   display: -ms-flexbox;
   display: -webkit-flex;
   display: flex;
   -webkit-align-items:center;
   -moz-align-items:center;
   -ms-align-items:center;
   align-items:center;
  }
  .jui_top_bar{ height:1.17333rem; line-height:1.17333rem; padding:0px 0.37333rem; background:#000; }
  .jui_top_left,.jui_top_right{ width:20%; color:#fff;}
  .jui_top_left img{ display:inline-block; height:.45333rem;}
  .jui_top_left span{ font-size:.32rem; color:#fff; padding-left:.16rem;}
  .jui_top_middle{ width:60%; text-align:center; overflow:hidden;text-overflow:ellipsis;white-space: nowrap; color:#fff;
  font-size:0.42666rem;}
  .jui_top_right{ font-size:0.32rem; cursor:pointer;
  -webkit-justify-content:flex-end;
  -moz-justify-content:flex-end;
  -ms-justify-content:flex-end;
  justify-content:flex-end;
  }
  .reg_box{ padding: 0.32rem 0.32rem 0;}
  .reg_details{ width: 100%; padding: 0.5rem;}
  .reg_list{ height: 1.1rem; margin-bottom: 0.3rem;}
  .reg_list input{ padding: 0 0.3rem; width: 100%; height: 0.7rem;}
  .reg_btn{ text-align: center; width: 70%; height: 0.8rem;
  margin-top: 0.7rem; line-height: 0.8rem; background: red; margin-left: 15%;
  }
  .reg_ma{
  height: 0.7rem; margin-top: 0.5rem; margin-bottom: 0.2rem;
  display:flex; display:-webkit-flex; -webkit-align-items:center; align-items:center;
  }
  .reg_ma_btn{ background: #666; height: 0.7rem;
  line-height: 0.7rem;
  display: flex;
  display: -webkit-flex;
  -webkit-align-items: center;
  align-items: center;
  padding: 0 0.3rem;}
  .reg_ma_input{ height:100%; flex:1; padding: 0 0.31rem;}
 </style>
</head>

<body>
 <!--头部-->
 <div class=" jui_top_bar">
  <a class="jui_top_left" href="javascript:history.back(-1)"><img src="icons/back.png"></a>
  <div class="jui_top_middle font_weight" data-ch="注册账号" data-en="Register">注册账号</div>
 </div>
 <!-- 头部end -->
 <!-- 内容列表部分 -->
 <div class="reg_box jui_main">
  <div class="reg_details border_radius05 latout_mask">
   <div class="reg_list">
    <div class="reg_list_title f30 col_fff" data-ch="手机号码:" data-en="Phone no.">手机号码:</div>
    <input id="reg_phone" maxlength="11" type="text">
   </div>
   <div class="reg_ma">
    <input type="button" class="reg_ma_btn f28 col_fff" id="get_yzm" data-ch="获取验证码" data-en="verification code"
     value="获取验证码">
    <input class="reg_ma_input" id="reg_yzm" maxlength="6" type="text">
   </div>
   <div class="reg_list">
    <div class="reg_list_title f30 col_fff" data-ch="全名:" data-en="Full name">全名:</div>
    <input type="text" id="reg_all_name">
   </div>
   <div class="reg_list">
    <div class="reg_list_title f30 col_fff" data-ch="账号名称:" data-en="User ID">账号名称:</div>
    <input type="text" id="reg_user_name">
   </div>
   <div class="reg_list">
    <div class="reg_list_title f30 col_fff" data-ch="电邮:" data-en="Email">电邮:</div>
    <input type="text" id="reg_email">
   </div>
   <div class="reg_list">
    <div class="reg_list_title f30 col_fff" data-ch="密码:" data-en="Password">密码:</div>
    <input type="password" id="reg_pass">
   </div>
   <div class="reg_list">
    <div class="reg_list_title f30 col_fff" data-ch="确认密码:" data-en="Confirm password">确认密码:</div>
    <input type="password" id="reg_sure_pass">
   </div>
   <div class="reg_list">
    <div class="reg_list_title f30 col_fff" data-ch="交易密码:" data-en="Secondary password">交易密码:</div>
    <input type="password" id="reg_jiaoyi_pass">
   </div>
   <div class="reg_list">
    <div class="reg_list_title f30 col_fff" data-ch="确认交易密码:" data-en="Confirm secondary password">确认交易密码:</div>
    <input type="password" id="reg_sure_jiaoyi_pass">
   </div>
   <div class="reg_list">
    <div class="reg_list_title f30 col_fff" data-ch="邀请码:" data-en="Invitation code">邀请码:</div>
    <input type="text" id="reg_yao_ma">
   </div>
   <div class="reg_btn col_fff" id="reg_btn" data-ch="注册" data-en="Register">注册</div>
  </div>
 </div>

 <!-- <script src="js/reg.js"></script> -->
 <script>
  $(function(){
   var language_type = localStorage.getItem('language_type');
   var maNum; // 验证码所剩的时间
   $(document).ready(function () {
   if (language_type == 2) {
   $("#get_yzm").attr("value", "Verification Code") // 如果是英文，替换value值
   }
   language();
   documentName()
   })
   // 验证码倒计时
   function settime(num) {
   var yzm_input = document.getElementById("get_yzm");
   var num;
   if (num == 0) {
   regcode = true;
   // console.log(language_type == 2)
   yzm_input.value = language_type == 1 ? "重新发送" : "Resend"
   yzm_input.removeAttribute("disabled");
   return false; //直到倒计时0时停止执行函数
   } else {
   yzm_input.setAttribute("disabled", "disabled");
   if (language_type == 1) {
   yzm_input.value = num + "s后重发";
   } else {
   yzm_input.value = "Resend after " + num + "s";
   }
   num--;
   maNum = num;
   }
   setTimeout("settime(" + num + ")", 1000);
   }
   $("#get_yzm").click(function () {
   let m_phone = $("#reg_phone").val(); // 手机号
   if (!/^((00){1}[1-9]{1}[0-9]{1,3}|86|\+86)?1[3458]\d{9}$/.test(m_phone)) {
   layer.open({
   content: language_type == 1 ? '手机号格式不正确' : 'Invalid phone number format',
   time: 1
   })
   } else {
   settime(60)
   let req1 = {
   type: 1,
   mobile: m_phone
   }
   $.ajax({
   type: 'post',
   url: baseURL + '/index.php?m=login&c=sms_code',
   data: req1,
   success: function success(data) {
   data = JSON.parse(data);
   if (data.code == 1) {
   layer.open({
   content: language_type == 1 ? '发送成功' : 'Sent successfully',
   time: 1
   });
   } else {
   layer.open({
   content: data.msg,
   time: 1
   });
   }
   }
   });
   }
   })

   $("#reg_btn").click(function () {
   // location.href = "login.html" // 跳转登录页
   let m_phone = $("#reg_phone").val(); // 手机号
   let m_code = $("#reg_yzm").val(); // 验证码
   let m_nickname = $("#reg_all_name").val(); // 全名
   let m_account = $("#reg_user_name").val(); // 账号名称
   let m_email = $("#reg_email").val(); // 电邮
   let m_login_pwd1 = $("#reg_pass").val(); // 密码
   let w_login_pwd2 = $("#reg_sure_pass").val(); // 确认密码
   let m_pay_pwd1 = $("#reg_jiaoyi_pass").val(); // 交易密码
   let m_pay_pwd2 = $("#reg_sure_jiaoyi_pass").val(); // 确认交易密码
   let m_invite_code = $("#reg_yao_ma").val(); // 邀请码
   var req2 = {
   m_invite_code: m_invite_code,
   language_type: language_type,
   m_nickname: m_nickname,
   m_phone: m_phone,
   m_code: m_code,
   m_login_pwd1: m_login_pwd1,
   w_login_pwd2: w_login_pwd2,
   m_pay_pwd1: m_pay_pwd1,
   m_pay_pwd2: m_pay_pwd2,
   m_account: m_account,
   m_email: m_email,
   };
   if (!/^1([38]\d|5[0-35-9]|7[3678])\d{8}$/.test(m_phone)) {
   layer.open({
   content: language_type == 1 ? '手机号格式不正确' : 'Invalid phone number format',
   time: 15
   })
   } else if (m_code != '123456') {
   layer.open({
   content: language_type == 1 ? '验证码错误' : 'Verification code error',
   time: 1
   })
   } else if (!m_nickname) {
   layer.open({
   content: language_type == 1 ? '请填写您的全名' : 'Please fill in your full name',
   time: 1
   })
   } else if (!m_account) {
   layer.open({
   content: language_type == 1 ? '请填写您的账号名称' : 'Please fill in your account name',
   time: 1
   })
   } else if (!/^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(m_email)) {
   layer.open({
   content: language_type == 1 ? '邮箱格式不正确' : 'Invalid email format ',
   time: 1
   })
   } else if (!/^[\w]{6,12}$/.test(m_login_pwd1)) {
   layer.open({
   content: language_type == 1 ? '请输入6-12位有效密码' : 'Please key in 6-12 characters',
   time: 1
   })
   } else if (w_login_pwd2 != m_login_pwd1) {
   layer.open({
   content: language_type == 1 ? '两次密码输入不一致' : 'Password did not match, Please try again',
   time: 1
   })
   } else if (!/^[\w]{6,12}$/.test(m_pay_pwd1)) {
   layer.open({
   content: language_type == 1 ? '请输入6-12位有效交易密码' : 'Please key in 6-12 characters',
   time: 1
   })
   } else if (m_pay_pwd1 != m_pay_pwd2) {
   layer.open({
   content: language_type == 1 ? '两次交易密码输入不一致' : 'Different input password',
   time: 1
   })
   } else if (!m_invite_code) {
   layer.open({
   content: language_type == 1 ? '请填写邀请码' : 'Please fill in the invitation code',
   time: 1
   })
   } else if (maNum == 0) {
   layer.open({
   content: language_type == 1 ? '验证码已失效,请重新发送' : 'Verification code has expired, please resend',
   time: 1
   })
   } else {
   $.ajax({
   type: 'post',
   url: baseURL + '/index.php?m=login&c=register',
   data: req2,
   success: function success(data) {
   data = JSON.parse(data);
   console.log(data.code == 1)
   if(data.code == 1){
   layer.open({
   content: data.msg,
   time: 1
   });
   setTimeout(function(){
   window.location.href = 'login.html'
   }, 1000);
   } else {
   layer.open({
   content: data.msg,
   time: 1
   });
   }
   }
   });
   }
   })

   

  })


 </script>
</body>

</html>